//
//  LandViewController.m
//  CatMusic
//
//  Created by dllo on 15/4/22.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "LandViewController.h"
#import "MyMusicViewController.h"
#import "RegisterViewController.h"
@interface LandViewController ()
@property (nonatomic , retain)UITextField *nameText;
@property (nonatomic , retain)UITextField *passWordText;
@end

@implementation LandViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"登陆";
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor orangeColor];
    // Do any additional setup after loading the view.
    UIView *landView = [[UIView alloc]initWithFrame:CGRectMake(50, 200, 50, 50)];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
    imageView.image = [UIImage imageNamed:@"iconfont-nanshangjia"];
    [landView addSubview:imageView];
//    landView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:landView];
    
    UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(40, 260, 100, 40)];
    name.text = @"用户名";
    name.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:name];
    
    self.nameText = [[UITextField alloc]initWithFrame:CGRectMake(140, 260, 200, 40)];
    self.nameText.placeholder = @"请输入用户名";
    self.nameText.layer.borderWidth = 1;
    self.nameText.layer.cornerRadius = 5;
    self.nameText.clearsOnBeginEditing = YES;
    self.nameText.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.nameText];
    
    
    UILabel *passWord = [[UILabel alloc]initWithFrame:CGRectMake(40, 320, 100, 40)];
    passWord.text = @"密码";
    passWord.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:passWord];
    
    self.passWordText = [[UITextField alloc]initWithFrame:CGRectMake(140, 320, 200, 40)];
    self.passWordText.layer.borderWidth = 1;
    self.passWordText.layer.cornerRadius = 5;
    self.passWordText.secureTextEntry = YES;
    self.passWordText.clearsOnBeginEditing = YES;
    self.passWordText.placeholder = @"请输入密码";
    self.passWordText.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.passWordText];
    
    
    UIButton *bu1 = [UIButton buttonWithType:UIButtonTypeSystem];
    bu1.frame = CGRectMake(70, 440, 80, 40);
    bu1.layer.borderWidth = 1;
    bu1.layer.cornerRadius = 5;
    bu1.backgroundColor = [UIColor redColor];
    [bu1 setTitle:@"登陆" forState:UIControlStateNormal];
    [bu1 addTarget:self action:@selector(cilckLand:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:bu1];
    
    UIButton *bu2 = [UIButton buttonWithType:UIButtonTypeSystem];
    bu2.frame = CGRectMake(220, 440, 80, 40);
    bu2.layer.borderWidth = 1;
    bu2.layer.cornerRadius = 5;
    bu2.backgroundColor = [UIColor redColor];
    [bu2 setTitle:@"注册" forState:UIControlStateNormal];
    [bu2 addTarget:self action:@selector(cilckRegister:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:bu2];
    
    
    
    // 释放内存
    [name release];
    [landView release];
    [passWord release];
    [imageView release];
    [_nameText release];
    [_passWordText release];
    
    
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.nameText resignFirstResponder];
    [self.passWordText resignFirstResponder];
}

- (void)cilckLand:(UIButton *)button
{
    MyMusicViewController *musicVC = [[MyMusicViewController alloc]init];
    [self.navigationController pushViewController:musicVC animated:YES];
}
- (void)cilckRegister:(UIButton *)button
{
    RegisterViewController *myRegister = [[RegisterViewController alloc]init];
    [self.navigationController pushViewController:myRegister animated:YES];
}

- (void)dealloc
{
    [_nameText release];
    [_passWordText release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
